//
//  HotListCell.m
//  PlayerFix
//
//  Created by DAT on 15/11/5.
//  Copyright © 2015年 DAT. All rights reserved.
//

#import "HotListCell.h"
#import <UIImageView+WebCache.h>
#import "HotListModel.h"

@implementation HotListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self creatSubviews];
        
    
    }
    return self;
}

- (void)creatSubviews{
        
    self.coverImg = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 80, 80)];
    self.coverImg.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.coverImg];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 20, 265, 30)];
    self.nameLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.nameLabel];
    
    
    self.viewCountImg = [[UIImageView alloc] initWithFrame:CGRectMake(100, 62.5, 15, 15)];
    self.viewCountImg.backgroundColor = [UIColor clearColor];
    self.viewCountImg.image = [UIImage imageNamed:@"listen.png"];
    [self.contentView addSubview: self.viewCountImg];
    
    self.viewCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(125, 60, 100, 20)];
    self.viewCountLabel.backgroundColor = [UIColor clearColor];
    self.viewCountLabel.font = [UIFont systemFontOfSize:12];
    self.viewCountLabel.textColor = [UIColor colorWithRed:0.41 green:0.41 blue:0.41 alpha:1.0];
    [self.contentView addSubview:self.viewCountLabel];
}

- (void)setHotListModel:(HotListModel *)hotListModel{
    
//    if (_hotListModel != hotListModel) {
//        
//        _hotListModel = hotListModel;
//    }
    _hotListModel = hotListModel;
    

    NSDictionary *dic = (NSDictionary *)_hotListModel;
    NSString *name = [dic objectForKey:@"name"];
    NSString *pic = [dic objectForKey:@"pic_200"];
    NSString *viewCount = [dic objectForKey:@"view_count"];
    
    [self.coverImg sd_setImageWithURL:[NSURL URLWithString:pic] placeholderImage:[UIImage imageNamed:@"holderPic_recommend.png"]];
    self.nameLabel.text = name;
    self.viewCountLabel.text = viewCount;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
